class Presentation(object):
    def plot_lines(self, *indexes):
        return self._plot_lines(True, *indexes)

    def plot(self, *indexes):
        return self._plot_lines(len(indexes) == 1, *indexes)

    def _plot_lines(self, use_range, *indexes):
        """ Create plot using matplotlib. """

        from plyny.presentation.plot import Plot

        if use_range:
            new_indexes = self._int_indexes_to_column_names(*self._indexes(*indexes))
            slc = self.slice(*indexes).enumerate().slice('n', *new_indexes)  # XXX
        else:
            slc = self.slice(*indexes)

        return Plot(slc)

    def table(self, cons=None):
        """ Returns `presentation.table` from data.

        :param cons: a presentation.table subclass used for constructing.
        :returns: a presentation.table with the values from this table.
        """

        if cons is None:
            from plyny.presentation.text import TextTable
            cons = TextTable

        if self.column_names is None:
            t = cons()
        else:
            t = cons(*self.column_names)

        [t.add(*x) for x in self.as_lists()]

        for i, v in enumerate(self.types()):
            if v == int:
                t.set_justification(i, cons.RIGHT)
            if v == float:
                t.set_justification(i, cons.RIGHT)
                t.set_format(i, '%0.3f')
        return t
